var startTime, endTime;

$(window).load(function () {
	startTime = new Date().getTime();
	//alert("Welcome!");
});

$(window).unload( function () {
	endTime = new Date().getTime();
	var period = endTime - startTime;
	var sencond = period / 1000;
	
	$.ajax({
		type: "POST",
		url: "/online",
		async: false,
		data: "period=" + period,
		success: function(msg){
			//alert("Update OnlineTime success!");
		},
		error: function(){
			alert("Update OnlineTime success!");					
		}
	});				

	//alert("Bye now! Stay second: " + sencond); 
});